home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Frameworks / Extension Shell 1.3 / Extension Shell 1.3 (Source) / AddrsTable.c next >
Encoding:
C/C++ Source or Header  |  1994-04-06  |  2.6 KB  |  96 lines  |  [TEXT/R*ch]

  1. /*    NAME:
  2.         AddrsTable.c
  3.  
  4.     WRITTEN BY:
  5.         Dair Grant
  6.  
  7.     DESCRIPTION:
  8.         This file contains a a code resource that acts as a Gestalt Selector
  9.         function to be installed as an address table. When called, it will
  10.         return the address of its internal address table. This is the most
  11.         flexible mechanism for code installed from an Extension to find out
  12.         the address of the thing it replaced.
  13.  
  14.     NOTES:
  15.         •    Compiled with THINK C 6.0.
  16.  
  17.         •    This code resource is generic and can be pasted into any INIT that
  18.             uses ExtensionShell.
  19.         
  20.         •    This code relies on a fixed size table - if the table changes
  21.             (see ESConstants.h.h), the code resource will need recompiled.
  22.  
  23.     ___________________________________________________________________________
  24.  
  25.     VERSION HISTORY:
  26.         (Jan 1994, dg)
  27.             •    First publicly distributed version.
  28.         
  29.             
  30.     ___________________________________________________________________________
  31. */
  32. //=============================================================================
  33. //        Include files                                                                     
  34. //-----------------------------------------------------------------------------
  35. #include "StandaloneCode.h"
  36. #include "AddrsTable.h"
  37.  
  38.  
  39.  
  40.  
  41.  
  42. //=============================================================================
  43. //        Function prototypes                                                                     
  44. //-----------------------------------------------------------------------------
  45. pascal OSErr main(OSType theSelector, long *theResponse);
  46.  
  47.  
  48.  
  49.  
  50.  
  51. //=============================================================================
  52. //        Global variables                                                                 
  53. //-----------------------------------------------------------------------------
  54. AddressTable    gTheAddressTable;
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65. //=============================================================================
  66. //        main : Entry point to our Gestalt Selector function.                                                                 
  67. //-----------------------------------------------------------------------------
  68. //        Note :    This code is used to store a table of ProcPtrs. This is set up
  69. //                by Extension Shell so that code installed into the System Heap
  70. //                can find out the address of the thing that replaced them.
  71. //
  72. //                We do not initialise gTheAddressTable. We assume that the first
  73. //                person to call us is ExtensionShell, and it initialises it.
  74. //-----------------------------------------------------------------------------
  75. pascal OSErr main(OSType theSelector, long *theResponse)
  76. {
  77.  
  78.  
  79.  
  80.  
  81.     // Set up A4 to get access to our globals
  82.     GetGlobals();
  83.  
  84.     
  85.             
  86.     // Return the address of gTheAddressTable. We treat theResponse as a pointer
  87.     // to a variable that's a pointer to an address table, and write to it
  88.     // accordingly.
  89.     *theResponse = (long) &gTheAddressTable;
  90.  
  91.  
  92.  
  93.     // Restore A4 for our caller.
  94.     UngetGlobals();
  95. }
  96.